﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Common;
using System.Data;
using DataAccessClasses;


namespace BUSINESS_OBJECT
{
    public class admincls
    {
        iDAC DAC = DACFactory.GetDAC();
        private long _ID = -99;
        private string _uname ="";
        private string _pswrd = "";
        private bool _isdeleted=false;


        public long ID
        {
            get
            {
                return _ID;
            }
            set
            {
                _ID = value;
            }
        }
        public string uname
        {
            get
            {
                return _uname;
            }
            set
            {
                _uname = value;

            }
        }
        public string pswrd
        {
            get
            {
                return _pswrd;
            }
            set
            {
                _pswrd = value;
            }
        }
        public bool isdeleted
        {
            get
            {
                return _isdeleted;
            }
            set
            {
                _isdeleted = value;
            }
        }

         public long SaveRecords()
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@ID", ID, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@USERNAME", uname, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@PASSWORD", pswrd, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@PARAANDOR", isdeleted, DbType.Boolean, ParameterDirection.Input);

                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2,dbparam3};
                return DAC.Save("admin_SAVE", dbparamcall);
            }
            catch (Exception ex)
            {
              long Result = -99;
            }
            return -99;
        }
        public DataTable GetRecords(long ID, string uname, string pswrd,bool isdeleted,string paraandor)
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@ID", ID, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@USERNAME", uname, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@PASSWORD", pswrd, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@ISDELETED", isdeleted, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam4 = DAC.Parameter("@PARAANDOR", paraandor, DbType.AnsiString, ParameterDirection.Input);
                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2,dbparam3,dbparam4 };

                return DAC.Select("admin_GET", dbparamcall); 
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return null;
        }




            
    }
}
